package com.project.picxg.interceptor;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class TokenInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        boolean valid = true;
        response.setCharacterEncoding("utf-8");
        String uid = request.getHeader("uid");
        System.out.println(uid);
        if (StringUtils.isBlank(uid)){
//            valid = false;
            System.out.println("验证失败！");
            response.setContentType("application/json; charset=utf-8");
        }
        return valid;
    }
}
